package com.bfxy.rabbitmq.dlx;

import com.bfxy.rabbitmq.util.RabbitUtil;
import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;

/**
 * Created by deng_wb on 2020/3/14
 */
@SuppressWarnings("all")
public class Producer {

    public static void main(String[] args) throws Exception{
        Channel channel = RabbitUtil.producerChannel();
        String exchange = "test_dlx_exchange";
        String routingKey = "dlx.save";

        String msg = "Hello RabbitMQ DLX Message";

        for (int i = 0; i < 2; i++) {

            AMQP.BasicProperties properties = new AMQP.BasicProperties.Builder()
                    .deliveryMode(2)
                    .contentEncoding("UTF-8")
                    .expiration("10000")
                    .build();
            channel.basicPublish(exchange,routingKey,true,properties,msg.getBytes());
        }
    }
}
